package com.arcaneshift.manager.action.game;

import java.util.ArrayList;
import java.util.List;

import com.arcaneshift.dao.action.game.DeckCardMapDao;
import com.arcaneshift.dao.interfaces.IDeckCardMapDao;
import com.arcaneshift.manager.interfaces.IDeckCardMapManager;
import com.arcaneshift.model.action.game.DeckCardMap;
import com.common.dao.interfaces.IDao;
import com.common.dao.util.Criteria;
import com.common.dao.util.QueryOperation;
import com.common.manager.abstracts.AbstractManager;
import com.common.security.exceptions.DatabaseException;
import com.common.security.exceptions.ManagerException;

public class DeckCardMapManager extends AbstractManager<DeckCardMap> implements IDeckCardMapManager {

	private IDeckCardMapDao mapDao;
	
	public DeckCardMapManager() {
		mapDao = new DeckCardMapDao();
	}
	
	@Override
	protected IDao<DeckCardMap> getDao() {
		return mapDao;
	}
	
	public List<DeckCardMap> getByDeckId(Long deckId) throws ManagerException {
		try {
			List<Criteria> criterias = new ArrayList<Criteria>();
			criterias.add(new Criteria(DeckCardMap.DECK_ID, deckId, QueryOperation.EQUALS, false));
			return mapDao.getByCriteria(criterias);
		} catch (DatabaseException databaseException) {
			throw new ManagerException(ManagerException.DATABASE_EXCEPTION);
		}
	}
}
